<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of sigma_gen</title>
  <meta name="keywords" content="sigma_gen">
  <meta name="description" content="">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">utilities</a> &gt; sigma_gen.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for utilities&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>sigma_gen
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong></strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function dist = sigma_gen(nlev,dl,du,kl,ku,zkl,zku,h,hmin) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="show_sigma.html" class="code" title="">show_sigma</a>	function [] = show_sigma(meshfile,bathfile,sigmafile)</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function dist = sigma_gen(nlev,dl,du,kl,ku,zkl,zku,h,hmin)</a>
0002 
0003 
0004  
0005   <span class="keyword">if</span>(h &lt; hmin)
0006     z(1) = 0.0;
0007     dl2=0.001;
0008     du2=0.001;
0009     <span class="keyword">for</span> k=1:nlev-1
0010       x1 = dl2+du2;
0011       x1 = x1*double(nlev-1-k)/double(nlev-1);
0012       x1 = x1 - dl2;
0013       x1 = tanh(x1);
0014       x2 = tanh(dl2);
0015       x3 = x2+tanh(du2);
0016       z(k+1) = (x1+x2)/x3-1.0;  
0017     <span class="keyword">end</span>;
0018   <span class="keyword">else</span>;
0019     <span class="comment">%dr=(h-sum(zku)-sum(zkl))/h/double(nlev-ku-kl-1);</span>
0020     dr=(h-du-dl)/h/double(nlev-ku-kl-1);
0021     z(1) = 0.0;
0022  
0023     <span class="keyword">for</span> k=2:ku+1 
0024        z(k) = z(k-1)-zku(k-1)/h;
0025   <span class="comment">%     fprintf('building z %f %f %f %f \n',z(k),zku(k-1),h,zku(k-1)/h)</span>
0026     <span class="keyword">end</span>;
0027 
0028     <span class="keyword">for</span> k=ku+2:nlev-kl
0029       z(k)=z(k-1)-dr;
0030   <span class="comment">%     fprintf('building z %f %f \n',z(k),dr)</span>
0031     <span class="keyword">end</span>;
0032 
0033     kk = 0;
0034     <span class="keyword">for</span> k=nlev-kl+1:nlev
0035       kk=kk+1;
0036       z(k)=z(k-1)-zkl(kk)/h;
0037   <span class="comment">%     fprintf('building z %f %f \n',z(k),zkl(kk))</span>
0038     <span class="keyword">end</span>;   
0039   <span class="keyword">end</span>;
0040   dist = z;</pre></div>
<hr><address>Generated on Wed 02-Nov-2011 21:58:00 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>